import 'package:flutter/material.dart';
import 'package:flutter_douban/tool_views/back_nav_btn.dart';
import 'package:flutter_douban/tool_views/nav_title_page.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'dart:io';

class ActivityDetail extends StatefulWidget {
  final String? url;
  final String? titleStr;
  const ActivityDetail({Key? key, required this.url, this.titleStr})
      : super(key: key);

  @override
  _ActivityDetailState createState() => _ActivityDetailState();
}

class _ActivityDetailState extends State<ActivityDetail> {
  @override
  void initState() {
    super.initState();
    // Enable hybrid composition.
    if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: NavTitlePage(
          titleStr: widget.titleStr!,
        ),
        leading: BackNavBtn(),
      ),
      body: WebView(
        initialUrl: widget.url,
        //JS执行模式 是否允许JS执行
        javascriptMode: JavascriptMode.unrestricted,
      ),
    );
  }
}
